home *** CD-ROM | disk | FTP | other *** search
- <!--- This example shows the use of CreateTimeSpan with CFQUERY --->
- <HTML>
- <HEAD>
- <TITLE>CreateTimeSpan Example</TITLE>
- </HEAD>
-
- <BODY bgcolor="#FFFFD4">
-
- <H3>CreateTimeSpan Example</H3>
-
- <!--- define startrow and maxrows to facilitate
- 'next N' style browsing --->
- <CFPARAM name="MaxRows" default="10">
- <CFPARAM name="StartRow" default="1">
-
- <!-----------------------------------------------------------------
- Query database for information if cached database information has
- not been updated in the last six hours; otherwise, use cached data.
- ------------------------------------------------------------------->
- <CFOUTPUT>
- <CFQUERY NAME="GetParks" DATASOURCE="cfsnippets" CACHEDWITHIN="#CreateTimeSpan(0, 6, 0, 0)#">
- SELECT PARKNAME, REGION, STATE
- FROM Parks
- ORDER by ParkName, State
- </CFQUERY>
- </CFOUTPUT>
-
- <!--- build HTML table to display query --->
- <TABLE cellpadding=1 cellspacing=1>
- <TR>
- <TD colspan=2 bgcolor=f0f0f0>
- <B><I>Park Name</I></B>
- </TD>
- <TD bgcolor=f0f0f0>
- <B><I>Region</I></B>
- </TD>
- <TD bgcolor=f0f0f0>
- <B><I>State</I></B>
- </TD>
- </TR>
-
- <!--- Output the query and define the startrow and maxrows
- parameters. Use the query variable CurrentCount to
- keep track of the row you are displaying. --->
- <CFOUTPUT query="GetParks" StartRow="#StartRow#" MAXROWS="#MaxRows#">
- <TR>
- <TD valign=top bgcolor=ffffed>
- <B>#GetParks.CurrentRow#</B>
- </TD>
- <TD valign=top>
- <FONT SIZE="-1">#ParkName#</FONT>
- </TD>
- <TD valign=top>
- <FONT SIZE="-1">#Region#</FONT>
- </TD>
- <TD valign=top>
- <FONT SIZE="-1">#State#</FONT>
- </TD>
- </TR>
- </CFOUTPUT>
-
- <!--- If the total number of records is less than or equal
- to the total number of rows, then offer a link to
- the same page, with the startrow value incremented by
- maxrows (in the case of this example, incremented by 10) --->
- <TR>
- <TD colspan=4>
- <CFIF (StartRow + MaxRows) LTE GetParks.RecordCount>
- <a href="cfquery.cfm?startrow=<CFOUTPUT>#Evaluate(StartRow + MaxRows)#</CFOUTPUT>">See next <CFOUTPUT>#MaxRows#</CFOUTPUT> rows</A>
- </CFIF>
-
- </TD>
- </TR>
- </TABLE>
- </BODY>
- </HTML>
-